// 网络图片调试地址 http://wx2.sinaimg.cn/mw690/ac38503ely1fesz8m0ov6j20qo140dix.jpg
var acc_token="";
var nick="";
var obj_nick="";
var head_url="";
var obj_head_url="";
var id="";
var obj_id="";
function calljs(type,value){
    var obj=eval('('+value+')');
    acc_token=obj.acc_token;
    nick=obj.nick;
    obj_nick=obj.obj_nick;
    head_url=obj.head_url;
    obj_head_url=obj.obj_head_url;
    id=obj.id;
    obj_id=obj.obj_id;
    // head_url="http://wx2.sinaimg.cn/mw690/ac38503ely1fesz8m0ov6j20qo140dix.jpg";
}
export default {
    AccToken:acc_token,//document.getElementById("AccToken").value,    
    Nick:nick,//document.getElementById("Nick").value,
    ObjNick:obj_nick,//document.getElementById("ObjNick").value,
    HeadUrl:head_url,//document.getElementById("HeadUrl").value,       //"../assets/user.png",        
    ObjHeadUrl:obj_head_url,//document.getElementById("ObjHeadUrl").value,   //"../assets/default.png",    
    Id:id,//document.getElementById("Id").value,
    ObjId:obj_id,//document.getElementById("ObjId").value,
    SendJsonToHttp:function(url,method,jsonStr){
        //在此之前可以判断下浏览器的版本
        var xhr=new XMLHttpRequest();  //new
        xhr.open(method,url,true);
        xhr.send(jsonStr); //发请求send(里面放数据)
        xhr.onreadystatechange=function(){
            if (xhr.readyState==4){
                if (xhr.status==200){
                    console.log(xhr.responseText);
                    return xhr.responseText;
                }
            }else{
                return `{"status":298,"msg":"没有请求成功"}`
            }
        }
    },
    GetAccToken:function(){
        return `{"acctoken":"`+this.AccToken+`"}`;
    },
    GetSendMsg:function(msg){
        return `{"from":"`+this.Id+`","to":"`+this.ObjId+`","time":`+getTimeStamp()+`,"msg":"`+msg+`"}`
    },
    ToJson:function(jsonStr){
        var o=JSON.parse(jsonStr);
        return o;
    },
    GetData:function(){
        // alert(this.AccToken+this.Nick+this.Id+this.ObjId+this.ObjNick);     
        console.log(this.AccToken+this.Nick+this.Id+this.ObjId+this.ObjNick+this.HeadUrl);               
        return this.Nick;
    }
}
function getTimeStamp(){
    var t = (new Date()).valueOf();
    return Math.round(t/1000);
}